package org.dawning.fantasy.core.common;


import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

/**
 * @author miou
 * Created by FengYixin on 2016/8/31.
 */
public abstract class BaseController {


    private BaseResult baseResult;

    public BaseResult sendResult(int code, String message) {
        return baseResult = new BaseResult(code, message);
    }

    public BaseResult sendResult(int code, String message, Object data) {
        return baseResult = new BaseResult(code, message, data);
    }
    public BaseResult sendResult(int code, String message, Object data,String mark) {
        if(data==null){
            if(mark.equals(Constants.RESULT_JSON_DATA_OBJECT)){
                data=new JsonObject();
            }else if(mark.equals(Constants.RESULT_JSON_DATA_COLLECTION)){
                data=new JsonArray();
            }
        }
        return baseResult = new BaseResult(code, message, data);
    }
    public BaseResult getBaseResult() {
        return baseResult;
    }

    public void setBaseResult(BaseResult baseResult) {
        this.baseResult = baseResult;
    }

}
